﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Collections.ObjectModel;

namespace Renci.Data.Interop.Test.OpenGIS.Swe
{
    /// <summary>
    /// Summary description for GenericListType
    /// </summary>
    [TestClass]
    public class GenericListType
    {
        public GenericListType()
        {
        }

        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        //
        // You can use the following additional attributes as you write your tests:
        //
        // Use ClassInitialize to run code before running the first test in the class
        // [ClassInitialize()]
        // public static void MyClassInitialize(TestContext testContext) { }
        //
        // Use ClassCleanup to run code after all tests in a class have run
        // [ClassCleanup()]
        // public static void MyClassCleanup() { }
        //
        // Use TestInitialize to run code before running each test 
        // [TestInitialize()]
        // public void MyTestInitialize() { }
        //
        // Use TestCleanup to run code after each test has run
        // [TestCleanup()]
        // public void MyTestCleanup() { }
        //
        #endregion


        [TestMethod]
        public void TestGenericListTypeImplicitConverstion1()
        {
            Renci.Data.Interop.OpenGIS.Swe.Common.GenericCollectionType<int> t1 = new Renci.Data.Interop.OpenGIS.Swe.Common.GenericCollectionType<int>();

            t1 = new Collection<int>() { 11, 23, 55 };
            Assert.IsTrue(t1.Value == "11 23 55", "Implicit conversion failed.");

            Collection<int> t2 = t1;
            Assert.IsTrue(t2.Count == 3, "Implicit conversion failed.");
            Assert.IsTrue(t2[0] == 11, "Implicit conversion failed.");
            Assert.IsTrue(t2[1] == 23, "Implicit conversion failed.");
            Assert.IsTrue(t2[2] == 55, "Implicit conversion failed.");

        }

        [TestMethod]
        public void TestGenericListTypeImplicitConverstion2()
        {
            Renci.Data.Interop.OpenGIS.Swe.Common.GenericCollectionType<double> t1 = new Renci.Data.Interop.OpenGIS.Swe.Common.GenericCollectionType<double>();

            t1 = new Collection<double>() { 11.22, 23.33, 55.44 };
            Assert.IsTrue(t1.Value == "11.22 23.33 55.44", "Implicit conversion failed.");

            Collection<double> t2 = t1;
            Assert.IsTrue(t2.Count == 3, "Implicit conversion failed.");
            Assert.IsTrue(t2[0] == 11.22, "Implicit conversion failed.");
            Assert.IsTrue(t2[1] == 23.33, "Implicit conversion failed.");
            Assert.IsTrue(t2[2] == 55.44, "Implicit conversion failed.");
        }

        [TestMethod]
        public void TestGenericListTypeImplicitConverstion3()
        {
            Renci.Data.Interop.OpenGIS.Swe.Common.GenericCollectionType<string> t1 = new Renci.Data.Interop.OpenGIS.Swe.Common.GenericCollectionType<string>();

            t1 = new Collection<string>() { "asd", "dsfg", "gsdfgsdfgsdfg" };
            Assert.IsTrue(t1.Value == "asd dsfg gsdfgsdfgsdfg", "Implicit conversion failed.");

            Collection<string> t2 = t1;
            Assert.IsTrue(t2.Count == 3, "Implicit conversion failed.");
            Assert.IsTrue(t2[0] == "asd", "Implicit conversion failed.");
            Assert.IsTrue(t2[1] == "dsfg", "Implicit conversion failed.");
            Assert.IsTrue(t2[2] == "gsdfgsdfgsdfg", "Implicit conversion failed.");
        }

    }
}
